// 使用mysql2模块
const mysql = require("mysql2");
// 连接mysql数据库 
const connection = mysql.createConnection({
    host: 'localhost',  //主机
    user: "root", //用户名
    password: "", //自己设置的密码
    database: "2201", //数据库名称
    charset: "utf8"
});

async function fn() {
    let sql = "SELECT * FROM products";
    let [rows] = await connection.promise().query(sql);
    console.log(rows);
}
fn()


